home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume9 / uemacs3.8b / part05 < prev    next >
Encoding:
Internet Message Format  |  1987-03-12  |  41.7 KB

  1. Subject:  v09i037:  MicroEMACS, version 3.8b, Part05/14
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.TMC.COM
  4.  
  5. Submitted by: ihnp4!itivax!duncan!lawrence (Daniel Lawrence)
  6. Mod.sources: Volume 9, Issue 37
  7. Archive-name: uemacs3.8b/Part05
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line,
  11. # then unpack it by saving it in a file and typing "sh file".
  12. # If this archive is complete, you will see the message:
  13. #        "End of archive 5 (of 14)."
  14. # Contents:  basic.c efunc.h termio.c
  15. # Wrapped by rs@mirror on Fri Mar 13 13:23:57 1987
  16. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  17. echo shar: Extracting \"basic.c\" \(12220 characters\)
  18. if test -f basic.c ; then 
  19.   echo shar: Will not over-write existing file \"basic.c\"
  20. else
  21. sed "s/^X//" >basic.c <<'END_OF_basic.c'
  22. X/*
  23. X * The routines in this file move the cursor around on the screen. They
  24. X * compute a new value for the cursor, then adjust ".". The display code
  25. X * always updates the cursor location, so only moves between lines, or
  26. X * functions that adjust the top line in the window and invalidate the
  27. X * framing, are hard.
  28. X */
  29. X#include        <stdio.h>
  30. X#include    "estruct.h"
  31. X#include        "edef.h"
  32. X
  33. X#if    MEGAMAX & ST520
  34. Xoverlay    "basic"
  35. X#endif
  36. X
  37. X/*
  38. X * Move the cursor to the
  39. X * beginning of the current line.
  40. X * Trivial.
  41. X */
  42. Xgotobol(f, n)
  43. X{
  44. X        curwp->w_doto  = 0;
  45. X        return (TRUE);
  46. X}
  47. X
  48. X/*
  49. X * Move the cursor backwards by "n" characters. If "n" is less than zero call
  50. X * "forwchar" to actually do the move. Otherwise compute the new cursor
  51. X * location. Error if you try and move out of the buffer. Set the flag if the
  52. X * line pointer for dot changes.
  53. X */
  54. Xbackchar(f, n)
  55. Xregister int    n;
  56. X{
  57. X        register LINE   *lp;
  58. X
  59. X        if (n < 0)
  60. X                return (forwchar(f, -n));
  61. X        while (n--) {
  62. X                if (curwp->w_doto == 0) {
  63. X                        if ((lp=lback(curwp->w_dotp)) == curbp->b_linep)
  64. X                                return (FALSE);
  65. X                        curwp->w_dotp  = lp;
  66. X                        curwp->w_doto  = llength(lp);
  67. X                        curwp->w_flag |= WFMOVE;
  68. X                } else
  69. X                        curwp->w_doto--;
  70. X        }
  71. X        return (TRUE);
  72. X}
  73. X
  74. X/*
  75. X * Move the cursor to the end of the current line. Trivial. No errors.
  76. X */
  77. Xgotoeol(f, n)
  78. X{
  79. X        curwp->w_doto  = llength(curwp->w_dotp);
  80. X        return (TRUE);
  81. X}
  82. X
  83. X/*
  84. X * Move the cursor forwwards by "n" characters. If "n" is less than zero call
  85. X * "backchar" to actually do the move. Otherwise compute the new cursor
  86. X * location, and move ".". Error if you try and move off the end of the
  87. X * buffer. Set the flag if the line pointer for dot changes.
  88. X */
  89. Xforwchar(f, n)
  90. Xregister int    n;
  91. X{
  92. X        if (n < 0)
  93. X                return (backchar(f, -n));
  94. X        while (n--) {
  95. X                if (curwp->w_doto == llength(curwp->w_dotp)) {
  96. X                        if (curwp->w_dotp == curbp->b_linep)
  97. X                                return (FALSE);
  98. X                        curwp->w_dotp  = lforw(curwp->w_dotp);
  99. X                        curwp->w_doto  = 0;
  100. X                        curwp->w_flag |= WFMOVE;
  101. X                } else
  102. X                        curwp->w_doto++;
  103. X        }
  104. X        return (TRUE);
  105. X}
  106. X
  107. Xgotoline(f, n)        /* move to a particular line.
  108. X               argument (n) must be a positive integer for
  109. X               this to actually do anything        */
  110. X
  111. X{
  112. X    register int status;    /* status return */
  113. X    char arg[NSTRING];    /* buffer to hold argument */
  114. X
  115. X    /* get an argument if one doesnt exist */
  116. X    if (f == FALSE) {
  117. X        if ((status = mlreply("Line to GOTO: ", arg, "")) != TRUE) {
  118. X            mlwrite("[Aborted]");
  119. X            return(status);
  120. X        }
  121. X        n = atoi(arg);
  122. X    }
  123. X
  124. X    if (n < 1)        /* if a bogus argument...then leave */
  125. X        return(FALSE);
  126. X
  127. X    /* first, we go to the start of the buffer */
  128. X        curwp->w_dotp  = lforw(curbp->b_linep);
  129. X        curwp->w_doto  = 0;
  130. X    return(forwline(f, n-1));
  131. X}
  132. X
  133. X/*
  134. X * Goto the beginning of the buffer. Massive adjustment of dot. This is
  135. X * considered to be hard motion; it really isn't if the original value of dot
  136. X * is the same as the new value of dot. Normally bound to "M-<".
  137. X */
  138. Xgotobob(f, n)
  139. X{
  140. X        curwp->w_dotp  = lforw(curbp->b_linep);
  141. X        curwp->w_doto  = 0;
  142. X        curwp->w_flag |= WFHARD;
  143. X        return (TRUE);
  144. X}
  145. X
  146. X/*
  147. X * Move to the end of the buffer. Dot is always put at the end of the file
  148. X * (ZJ). The standard screen code does most of the hard parts of update.
  149. X * Bound to "M->".
  150. X */
  151. Xgotoeob(f, n)
  152. X{
  153. X        curwp->w_dotp  = curbp->b_linep;
  154. X        curwp->w_doto  = 0;
  155. X        curwp->w_flag |= WFHARD;
  156. X        return (TRUE);
  157. X}
  158. X
  159. X/*
  160. X * Move forward by full lines. If the number of lines to move is less than
  161. X * zero, call the backward line function to actually do it. The last command
  162. X * controls how the goal column is set. Bound to "C-N". No errors are
  163. X * possible.
  164. X */
  165. Xforwline(f, n)
  166. X{
  167. X        register LINE   *dlp;
  168. X
  169. X        if (n < 0)
  170. X                return (backline(f, -n));
  171. X
  172. X    /* if we are on the last line as we start....fail the command */
  173. X    if (curwp->w_dotp == curbp->b_linep)
  174. X        return(FALSE);
  175. X
  176. X    /* if the last command was not note a line move,
  177. X       reset the goal column */
  178. X        if ((lastflag&CFCPCN) == 0)
  179. X                curgoal = getccol(FALSE);
  180. X
  181. X    /* flag this command as a line move */
  182. X        thisflag |= CFCPCN;
  183. X
  184. X    /* and move the point down */
  185. X        dlp = curwp->w_dotp;
  186. X        while (n-- && dlp!=curbp->b_linep)
  187. X                dlp = lforw(dlp);
  188. X
  189. X    /* reseting the current position */
  190. X        curwp->w_dotp  = dlp;
  191. X        curwp->w_doto  = getgoal(dlp);
  192. X        curwp->w_flag |= WFMOVE;
  193. X        return (TRUE);
  194. X}
  195. X
  196. X/*
  197. X * This function is like "forwline", but goes backwards. The scheme is exactly
  198. X * the same. Check for arguments that are less than zero and call your
  199. X * alternate. Figure out the new line and call "movedot" to perform the
  200. X * motion. No errors are possible. Bound to "C-P".
  201. X */
  202. Xbackline(f, n)
  203. X{
  204. X        register LINE   *dlp;
  205. X
  206. X        if (n < 0)
  207. X                return (forwline(f, -n));
  208. X
  209. X
  210. X    /* if we are on the last line as we start....fail the command */
  211. X    if (lback(curwp->w_dotp) == curbp->b_linep)
  212. X        return(FALSE);
  213. X
  214. X    /* if the last command was not note a line move,
  215. X       reset the goal column */
  216. X        if ((lastflag&CFCPCN) == 0)
  217. X                curgoal = getccol(FALSE);
  218. X
  219. X    /* flag this command as a line move */
  220. X        thisflag |= CFCPCN;
  221. X
  222. X    /* and move the point up */
  223. X        dlp = curwp->w_dotp;
  224. X        while (n-- && lback(dlp)!=curbp->b_linep)
  225. X                dlp = lback(dlp);
  226. X
  227. X    /* reseting the current position */
  228. X        curwp->w_dotp  = dlp;
  229. X        curwp->w_doto  = getgoal(dlp);
  230. X        curwp->w_flag |= WFMOVE;
  231. X        return (TRUE);
  232. X}
  233. X
  234. X#if    WORDPRO
  235. Xgotobop(f, n)    /* go back to the beginning of the current paragraph
  236. X           here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
  237. X           combination to delimit the beginning of a paragraph    */
  238. X
  239. Xint f, n;    /* default Flag & Numeric argument */
  240. X
  241. X{
  242. X    register int suc;    /* success of last backchar */
  243. X
  244. X    if (n < 0)    /* the other way...*/
  245. X        return(gotoeop(f, -n));
  246. X
  247. X    while (n-- > 0) {    /* for each one asked for */
  248. X
  249. X        /* first scan back until we are in a word */
  250. X        suc = backchar(FALSE, 1);
  251. X        while (!inword() && suc)
  252. X            suc = backchar(FALSE, 1);
  253. X        curwp->w_doto = 0;    /* and go to the B-O-Line */
  254. X
  255. X        /* and scan back until we hit a <NL><NL> or <NL><TAB>
  256. X           or a <NL><SPACE>                    */
  257. X        while (lback(curwp->w_dotp) != curbp->b_linep)
  258. X            if (llength(curwp->w_dotp) != 0 &&
  259. X                lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
  260. X                lgetc(curwp->w_dotp, curwp->w_doto) != ' ')
  261. X                curwp->w_dotp = lback(curwp->w_dotp);
  262. X            else
  263. X                break;
  264. X
  265. X        /* and then forward until we are in a word */
  266. X        suc = forwchar(FALSE, 1);
  267. X        while (suc && !inword())
  268. X            suc = forwchar(FALSE, 1);
  269. X    }
  270. X    curwp->w_flag |= WFMOVE;    /* force screen update */
  271. X    return(TRUE);
  272. X}
  273. X
  274. Xgotoeop(f, n)    /* go forword to the end of the current paragraph
  275. X           here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
  276. X           combination to delimit the beginning of a paragraph    */
  277. X
  278. Xint f, n;    /* default Flag & Numeric argument */
  279. X
  280. X{
  281. X    register int suc;    /* success of last backchar */
  282. X
  283. X    if (n < 0)    /* the other way...*/
  284. X        return(gotobop(f, -n));
  285. X
  286. X    while (n-- > 0) {    /* for each one asked for */
  287. X
  288. X        /* first scan forward until we are in a word */
  289. X        suc = forwchar(FALSE, 1);
  290. X        while (!inword() && suc)
  291. X            suc = forwchar(FALSE, 1);
  292. X        curwp->w_doto = 0;    /* and go to the B-O-Line */
  293. X        if (suc)    /* of next line if not at EOF */
  294. X            curwp->w_dotp = lforw(curwp->w_dotp);
  295. X
  296. X        /* and scan forword until we hit a <NL><NL> or <NL><TAB>
  297. X           or a <NL><SPACE>                    */
  298. X        while (curwp->w_dotp != curbp->b_linep) {
  299. X            if (llength(curwp->w_dotp) != 0 &&
  300. X                lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
  301. X                lgetc(curwp->w_dotp, curwp->w_doto) != ' ')
  302. X                curwp->w_dotp = lforw(curwp->w_dotp);
  303. X            else
  304. X                break;
  305. X        }
  306. X
  307. X        /* and then backward until we are in a word */
  308. X        suc = backchar(FALSE, 1);
  309. X        while (suc && !inword()) {
  310. X            suc = backchar(FALSE, 1);
  311. X        }
  312. X        curwp->w_doto = llength(curwp->w_dotp);    /* and to the EOL */
  313. X    }
  314. X    curwp->w_flag |= WFMOVE;    /* force screen update */
  315. X    return(TRUE);
  316. X}
  317. X#endif
  318. X
  319. X/*
  320. X * This routine, given a pointer to a LINE, and the current cursor goal
  321. X * column, return the best choice for the offset. The offset is returned.
  322. X * Used by "C-N" and "C-P".
  323. X */
  324. Xgetgoal(dlp)
  325. Xregister LINE   *dlp;
  326. X{
  327. X        register int    c;
  328. X        register int    col;
  329. X        register int    newcol;
  330. X        register int    dbo;
  331. X
  332. X        col = 0;
  333. X        dbo = 0;
  334. X        while (dbo != llength(dlp)) {
  335. X                c = lgetc(dlp, dbo);
  336. X                newcol = col;
  337. X                if (c == '\t')
  338. X                        newcol |= 0x07;
  339. X                else if (c<0x20 || c==0x7F)
  340. X                        ++newcol;
  341. X                ++newcol;
  342. X                if (newcol > curgoal)
  343. X                        break;
  344. X                col = newcol;
  345. X                ++dbo;
  346. X        }
  347. X        return (dbo);
  348. X}
  349. X
  350. X/*
  351. X * Scroll forward by a specified number of lines, or by a full page if no
  352. X * argument. Bound to "C-V". The "2" in the arithmetic on the window size is
  353. X * the overlap; this value is the default overlap value in ITS EMACS. Because
  354. X * this zaps the top line in the display window, we have to do a hard update.
  355. X */
  356. Xforwpage(f, n)
  357. Xregister int    n;
  358. X{
  359. X        register LINE   *lp;
  360. X
  361. X        if (f == FALSE) {
  362. X                n = curwp->w_ntrows - 2;        /* Default scroll.      */
  363. X                if (n <= 0)                     /* Forget the overlap   */
  364. X                        n = 1;                  /* if tiny window.      */
  365. X        } else if (n < 0)
  366. X                return (backpage(f, -n));
  367. X#if     CVMVAS
  368. X        else                                    /* Convert from pages   */
  369. X                n *= curwp->w_ntrows;           /* to lines.            */
  370. X#endif
  371. X        lp = curwp->w_linep;
  372. X        while (n-- && lp!=curbp->b_linep)
  373. X                lp = lforw(lp);
  374. X        curwp->w_linep = lp;
  375. X        curwp->w_dotp  = lp;
  376. X        curwp->w_doto  = 0;
  377. X        curwp->w_flag |= WFHARD;
  378. X        return (TRUE);
  379. X}
  380. X
  381. X/*
  382. X * This command is like "forwpage", but it goes backwards. The "2", like
  383. X * above, is the overlap between the two windows. The value is from the ITS
  384. X * EMACS manual. Bound to "M-V". We do a hard update for exactly the same
  385. X * reason.
  386. X */
  387. Xbackpage(f, n)
  388. Xregister int    n;
  389. X{
  390. X        register LINE   *lp;
  391. X
  392. X        if (f == FALSE) {
  393. X                n = curwp->w_ntrows - 2;        /* Default scroll.      */
  394. X                if (n <= 0)                     /* Don't blow up if the */
  395. X                        n = 1;                  /* window is tiny.      */
  396. X        } else if (n < 0)
  397. X                return (forwpage(f, -n));
  398. X#if     CVMVAS
  399. X        else                                    /* Convert from pages   */
  400. X                n *= curwp->w_ntrows;           /* to lines.            */
  401. X#endif
  402. X        lp = curwp->w_linep;
  403. X        while (n-- && lback(lp)!=curbp->b_linep)
  404. X                lp = lback(lp);
  405. X        curwp->w_linep = lp;
  406. X        curwp->w_dotp  = lp;
  407. X        curwp->w_doto  = 0;
  408. X        curwp->w_flag |= WFHARD;
  409. X        return (TRUE);
  410. X}
  411. X
  412. X/*
  413. X * Set the mark in the current window to the value of "." in the window. No
  414. X * errors are possible. Bound to "M-.".
  415. X */
  416. Xsetmark(f, n)
  417. X{
  418. X        curwp->w_markp = curwp->w_dotp;
  419. X        curwp->w_marko = curwp->w_doto;
  420. X        mlwrite("[Mark set]");
  421. X        return (TRUE);
  422. X}
  423. X
  424. X/*
  425. X * Swap the values of "." and "mark" in the current window. This is pretty
  426. X * easy, bacause all of the hard work gets done by the standard routine
  427. X * that moves the mark about. The only possible error is "no mark". Bound to
  428. X * "C-X C-X".
  429. X */
  430. Xswapmark(f, n)
  431. X{
  432. X        register LINE   *odotp;
  433. X        register int    odoto;
  434. X
  435. X        if (curwp->w_markp == NULL) {
  436. X                mlwrite("No mark in this window");
  437. X                return (FALSE);
  438. X        }
  439. X        odotp = curwp->w_dotp;
  440. X        odoto = curwp->w_doto;
  441. X        curwp->w_dotp  = curwp->w_markp;
  442. X        curwp->w_doto  = curwp->w_marko;
  443. X        curwp->w_markp = odotp;
  444. X        curwp->w_marko = odoto;
  445. X        curwp->w_flag |= WFMOVE;
  446. X        return (TRUE);
  447. X}
  448. END_OF_basic.c
  449. if test 12220 -ne `wc -c <basic.c`; then
  450.     echo shar: \"basic.c\" unpacked with wrong size!
  451. fi
  452. # end of overwriting check
  453. fi
  454. echo shar: Extracting \"efunc.h\" \(14637 characters\)
  455. if test -f efunc.h ; then 
  456.   echo shar: Will not over-write existing file \"efunc.h\"
  457. else
  458. sed "s/^X//" >efunc.h <<'END_OF_efunc.h'
  459. X/*    EFUNC.H:    MicroEMACS function declarations and names
  460. X
  461. X        This file list all the C code functions used by MicroEMACS
  462. X    and the names to use to bind keys to them. To add functions,
  463. X    declare it here in both the extern function list and the name
  464. X    binding table.
  465. X
  466. X*/
  467. X
  468. X/*    External function declarations        */
  469. X
  470. Xextern  int     ctrlg();                /* Abort out of things          */
  471. Xextern  int     quit();                 /* Quit                         */
  472. Xextern  int     ctlxlp();               /* Begin macro                  */
  473. Xextern  int     ctlxrp();               /* End macro                    */
  474. Xextern  int     ctlxe();                /* Execute macro                */
  475. Xextern  int     fileread();             /* Get a file, read only        */
  476. Xextern  int     filefind();        /* Get a file, read write       */
  477. Xextern  int     filewrite();            /* Write a file                 */
  478. Xextern  int     filesave();             /* Save current file            */
  479. Xextern  int     filename();             /* Adjust file name             */
  480. Xextern  int     getccol();              /* Get current column           */
  481. Xextern  int     gotobol();              /* Move to start of line        */
  482. Xextern  int     forwchar();             /* Move forward by characters   */
  483. Xextern  int     gotoeol();              /* Move to end of line          */
  484. Xextern  int     backchar();             /* Move backward by characters  */
  485. Xextern  int     forwline();             /* Move forward by lines        */
  486. Xextern  int     backline();             /* Move backward by lines       */
  487. Xextern  int     forwpage();             /* Move forward by pages        */
  488. Xextern  int     backpage();             /* Move backward by pages       */
  489. Xextern  int     gotobob();              /* Move to start of buffer      */
  490. Xextern  int     gotoeob();              /* Move to end of buffer        */
  491. Xextern  int     setfillcol();           /* Set fill column.             */
  492. Xextern  int     setmark();              /* Set mark                     */
  493. Xextern  int     swapmark();             /* Swap "." and mark            */
  494. Xextern  int     forwsearch();           /* Search forward               */
  495. Xextern  int     backsearch();           /* Search backwards             */
  496. Xextern    int    sreplace();        /* search and replace        */
  497. Xextern    int    qreplace();        /* search and replace w/query    */
  498. Xextern  int     showcpos();             /* Show the cursor position     */
  499. Xextern  int     nextwind();             /* Move to the next window      */
  500. Xextern  int     prevwind();             /* Move to the previous window  */
  501. Xextern  int     onlywind();             /* Make current window only one */
  502. Xextern  int     splitwind();            /* Split current window         */
  503. Xextern  int     mvdnwind();             /* Move window down             */
  504. Xextern  int     mvupwind();             /* Move window up               */
  505. Xextern  int     enlargewind();          /* Enlarge display window.      */
  506. Xextern  int     shrinkwind();           /* Shrink window.               */
  507. Xextern  int     listbuffers();          /* Display list of buffers      */
  508. Xextern  int     usebuffer();            /* Switch a window to a buffer  */
  509. Xextern  int     killbuffer();           /* Make a buffer go away.       */
  510. Xextern  int     reposition();           /* Reposition window            */
  511. Xextern  int     refresh();              /* Refresh the screen           */
  512. Xextern  int     twiddle();              /* Twiddle characters           */
  513. Xextern  int     tab();                  /* Insert tab                   */
  514. Xextern  int     newline();              /* Insert CR-LF                 */
  515. Xextern  int     indent();               /* Insert CR-LF, then indent    */
  516. Xextern  int     openline();             /* Open up a blank line         */
  517. Xextern  int     deblank();              /* Delete blank lines           */
  518. Xextern  int     quote();                /* Insert literal               */
  519. Xextern  int     backword();             /* Backup by words              */
  520. Xextern  int     forwword();             /* Advance by words             */
  521. Xextern  int     forwdel();              /* Forward delete               */
  522. Xextern  int     backdel();              /* Backward delete              */
  523. Xextern  int     killtext();             /* Kill forward                 */
  524. Xextern  int     yank();                 /* Yank back from killbuffer.   */
  525. Xextern  int     upperword();            /* Upper case word.             */
  526. Xextern  int     lowerword();            /* Lower case word.             */
  527. Xextern  int     upperregion();          /* Upper case region.           */
  528. Xextern  int     lowerregion();          /* Lower case region.           */
  529. Xextern  int     capword();              /* Initial capitalize word.     */
  530. Xextern  int     delfword();             /* Delete forward word.         */
  531. Xextern  int     delbword();             /* Delete backward word.        */
  532. Xextern  int     killregion();           /* Kill region.                 */
  533. Xextern  int     copyregion();           /* Copy region to kill buffer.  */
  534. Xextern  int     spawncli();             /* Run CLI in a subjob.         */
  535. Xextern  int     spawn();                /* Run a command in a subjob.   */
  536. X#if    BSD
  537. Xextern    int    bktoshell();        /* suspend emacs to parent shell*/
  538. Xextern    int    rtfrmshell();        /* return from a suspended state*/
  539. X#endif
  540. Xextern  int     quickexit();            /* low keystroke style exit.    */
  541. Xextern    int    setmode();        /* set an editor mode        */
  542. Xextern    int    delmode();        /* delete a mode        */
  543. Xextern    int    gotoline();        /* go to a numbered line    */
  544. Xextern    int    namebuffer();        /* rename the current buffer    */
  545. X#if    WORDPRO
  546. Xextern    int    gotobop();        /* go to beginning/paragraph    */
  547. Xextern    int    gotoeop();        /* go to end/paragraph        */
  548. Xextern    int    fillpara();        /* fill current paragraph    */
  549. X#endif
  550. Xextern    int    help();            /* get the help file here    */
  551. Xextern    int    deskey();        /* describe a key's binding    */
  552. Xextern    int    viewfile();        /* find a file in view mode    */
  553. Xextern    int    insfile();        /* insert a file        */
  554. Xextern    int    scrnextup();        /* scroll next window back    */
  555. Xextern    int    scrnextdw();        /* scroll next window down    */
  556. Xextern    int    bindtokey();        /* bind a function to a key    */
  557. Xextern    int    unbindkey();        /* unbind a key's function    */
  558. Xextern    int    namedcmd();        /* execute named command    */
  559. Xextern    int    desbind();        /* describe bindings        */
  560. Xextern    int    execcmd();        /* execute a command line    */
  561. Xextern    int    execbuf();        /* exec commands from a buffer    */
  562. Xextern    int    execfile();        /* exec commands from a file    */
  563. Xextern    int    nextbuffer();        /* switch to the next buffer    */
  564. X#if    WORDPRO
  565. Xextern    int    killpara();        /* kill the current paragraph    */
  566. X#endif
  567. Xextern    int    setgmode();        /* set a global mode        */
  568. Xextern    int    delgmode();        /* delete a global mode        */
  569. Xextern    int    insspace();        /* insert a space forword    */
  570. Xextern    int    forwhunt();        /* hunt forward for next match    */
  571. Xextern    int    backhunt();        /* hunt backwards for next match*/
  572. Xextern    int    pipe();            /* pipe command into buffer    */
  573. Xextern    int    filter();        /* filter buffer through dos    */
  574. Xextern    int    delwind();        /* delete the current window    */
  575. Xextern    int    cbuf1();        /* execute numbered comd buffer */
  576. Xextern    int    cbuf2();
  577. Xextern    int    cbuf3();
  578. Xextern    int    cbuf4();
  579. Xextern    int    cbuf5();
  580. Xextern    int    cbuf6();
  581. Xextern    int    cbuf7();
  582. Xextern    int    cbuf8();
  583. Xextern    int    cbuf9();
  584. Xextern    int    cbuf10();
  585. Xextern    int    cbuf11();
  586. Xextern    int    cbuf12();
  587. Xextern    int    cbuf13();
  588. Xextern    int    cbuf14();
  589. Xextern    int    cbuf15();
  590. Xextern    int    cbuf16();
  591. Xextern    int    cbuf17();
  592. Xextern    int    cbuf18();
  593. Xextern    int    cbuf19();
  594. Xextern    int    cbuf20();
  595. Xextern    int    cbuf21();
  596. Xextern    int    cbuf22();
  597. Xextern    int    cbuf23();
  598. Xextern    int    cbuf24();
  599. Xextern    int    cbuf25();
  600. Xextern    int    cbuf26();
  601. Xextern    int    cbuf27();
  602. Xextern    int    cbuf28();
  603. Xextern    int    cbuf29();
  604. Xextern    int    cbuf30();
  605. Xextern    int    cbuf31();
  606. Xextern    int    cbuf32();
  607. Xextern    int    cbuf33();
  608. Xextern    int    cbuf34();
  609. Xextern    int    cbuf35();
  610. Xextern    int    cbuf36();
  611. Xextern    int    cbuf37();
  612. Xextern    int    cbuf38();
  613. Xextern    int    cbuf39();
  614. Xextern    int    cbuf40();
  615. Xextern    int    storemac();        /* store text for macro        */
  616. Xextern    int    resize();        /* resize current window    */
  617. Xextern    int    clrmes();        /* clear the message line    */
  618. Xextern    int    meta();            /* meta prefix dummy function    */
  619. Xextern    int    cex();            /* ^X prefix dummy function    */
  620. Xextern    int    unarg();        /* ^U repeat arg dummy function    */
  621. Xextern    int    istring();        /* insert string in text    */
  622. Xextern    int    unmark();        /* unmark current buffer    */
  623. X#if    ISRCH
  624. Xextern    int    fisearch();        /* forward incremental search    */
  625. Xextern    int    risearch();        /* reverse incremental search    */
  626. X#endif
  627. X#if    WORDPRO
  628. Xextern    int    wordcount();        /* count words in region    */
  629. X#endif
  630. Xextern    int    savewnd();        /* save current window        */
  631. Xextern    int    restwnd();        /* restore current window    */
  632. Xextern    int    upscreen();        /* force screen update        */
  633. Xextern    int    writemsg();        /* write text on message line    */
  634. X#if    FLABEL
  635. Xextern    int    fnclabel();        /* set function key label    */
  636. X#endif
  637. X#if    APROP
  638. Xextern    int    apro();            /* apropos fuction        */
  639. X#endif
  640. X#if    CRYPT
  641. Xextern    int    setkey();        /* set encryption key        */
  642. X#endif
  643. Xextern    int    wrapword();        /* wordwrap function        */
  644. X#if    CFENCE
  645. Xextern    int    getfence();        /* move cursor to a matching fence */
  646. X#endif
  647. Xextern    int    newsize();        /* change the current screen size */
  648. Xextern    int    setvar();        /* set a variables value */
  649. Xextern    int    newwidth();        /* change the current screen width */
  650. X
  651. X/*    Name to function binding table
  652. X
  653. X        This table gives the names of all the bindable functions
  654. X    end their C function address. These are used for the bind-to-key
  655. X    function.
  656. X*/
  657. X
  658. XNBIND    names[] = {
  659. X    {"abort-command",        ctrlg},
  660. X    {"add-mode",            setmode},
  661. X    {"add-global-mode",        setgmode},
  662. X#if    APROP
  663. X    {"apropos",            apro},
  664. X#endif
  665. X    {"backward-character",        backchar},
  666. X    {"begin-macro",            ctlxlp},
  667. X    {"beginning-of-file",        gotobob},
  668. X    {"beginning-of-line",        gotobol},
  669. X    {"bind-to-key",            bindtokey},
  670. X    {"buffer-position",        showcpos},
  671. X    {"case-region-lower",        lowerregion},
  672. X    {"case-region-upper",        upperregion},
  673. X    {"case-word-capitalize",    capword},
  674. X    {"case-word-lower",        lowerword},
  675. X    {"case-word-upper",        upperword},
  676. X    {"change-file-name",        filename},
  677. X    {"change-screen-size",        newsize},
  678. X    {"change-screen-width",        newwidth},
  679. X    {"clear-and-redraw",        refresh},
  680. X    {"clear-message-line",        clrmes},
  681. X    {"copy-region",            copyregion},
  682. X#if    WORDPRO
  683. X    {"count-words",            wordcount},
  684. X#endif
  685. X    {"ctlx-prefix",            cex},
  686. X    {"delete-blank-lines",        deblank},
  687. X    {"delete-buffer",        killbuffer},
  688. X    {"delete-mode",            delmode},
  689. X    {"delete-global-mode",        delgmode},
  690. X    {"delete-next-character",    forwdel},
  691. X    {"delete-next-word",        delfword},
  692. X    {"delete-other-windows",    onlywind},
  693. X    {"delete-previous-character",    backdel},
  694. X    {"delete-previous-word",    delbword},
  695. X    {"delete-window",        delwind},
  696. X    {"describe-bindings",        desbind},
  697. X    {"describe-key",        deskey},
  698. X    {"end-macro",            ctlxrp},
  699. X    {"end-of-file",            gotoeob},
  700. X    {"end-of-line",            gotoeol},
  701. X    {"exchange-point-and-mark",    swapmark},
  702. X    {"execute-buffer",        execbuf},
  703. X    {"execute-command-line",    execcmd},
  704. X    {"execute-file",        execfile},
  705. X    {"execute-macro",        ctlxe},
  706. X    {"execute-macro-1",        cbuf1},
  707. X    {"execute-macro-2",        cbuf2},
  708. X    {"execute-macro-3",        cbuf3},
  709. X    {"execute-macro-4",        cbuf4},
  710. X    {"execute-macro-5",        cbuf5},
  711. X    {"execute-macro-6",        cbuf6},
  712. X    {"execute-macro-7",        cbuf7},
  713. X    {"execute-macro-8",        cbuf8},
  714. X    {"execute-macro-9",        cbuf9},
  715. X    {"execute-macro-10",        cbuf10},
  716. X    {"execute-macro-11",        cbuf11},
  717. X    {"execute-macro-12",        cbuf12},
  718. X    {"execute-macro-13",        cbuf13},
  719. X    {"execute-macro-14",        cbuf14},
  720. X    {"execute-macro-15",        cbuf15},
  721. X    {"execute-macro-16",        cbuf16},
  722. X    {"execute-macro-17",        cbuf17},
  723. X    {"execute-macro-18",        cbuf18},
  724. X    {"execute-macro-19",        cbuf19},
  725. X    {"execute-macro-20",        cbuf20},
  726. X    {"execute-macro-21",        cbuf21},
  727. X    {"execute-macro-22",        cbuf22},
  728. X    {"execute-macro-23",        cbuf23},
  729. X    {"execute-macro-24",        cbuf24},
  730. X    {"execute-macro-25",        cbuf25},
  731. X    {"execute-macro-26",        cbuf26},
  732. X    {"execute-macro-27",        cbuf27},
  733. X    {"execute-macro-28",        cbuf28},
  734. X    {"execute-macro-29",        cbuf29},
  735. X    {"execute-macro-30",        cbuf30},
  736. X    {"execute-macro-31",        cbuf31},
  737. X    {"execute-macro-32",        cbuf32},
  738. X    {"execute-macro-33",        cbuf33},
  739. X    {"execute-macro-34",        cbuf34},
  740. X    {"execute-macro-35",        cbuf35},
  741. X    {"execute-macro-36",        cbuf36},
  742. X    {"execute-macro-37",        cbuf37},
  743. X    {"execute-macro-38",        cbuf38},
  744. X    {"execute-macro-39",        cbuf39},
  745. X    {"execute-macro-40",        cbuf40},
  746. X    {"execute-named-command",    namedcmd},
  747. X    {"exit-emacs",            quit},
  748. X#if    WORDPRO
  749. X    {"fill-paragraph",        fillpara},
  750. X#endif
  751. X    {"filter-buffer",        filter},
  752. X    {"find-file",            filefind},
  753. X    {"forward-character",        forwchar},
  754. X    {"goto-line",            gotoline},
  755. X#if    CFENCE
  756. X    {"goto-matching-fence",        getfence},
  757. X#endif
  758. X    {"grow-window",            enlargewind},
  759. X    {"handle-tab",            tab},
  760. X    {"hunt-forward",        forwhunt},
  761. X    {"hunt-backward",        backhunt},
  762. X    {"help",            help},
  763. X    {"i-shell",            spawncli},
  764. X#if    ISRCH
  765. X    {"incremental-search",        fisearch},
  766. X#endif
  767. X    {"insert-file",            insfile},
  768. X    {"insert-space",        insspace},
  769. X    {"insert-string",        istring},
  770. X#if    WORDPRO
  771. X    {"kill-paragraph",        killpara},
  772. X#endif
  773. X    {"kill-region",            killregion},
  774. X    {"kill-to-end-of-line",        killtext},
  775. X#if    FLABEL
  776. X    {"label-function-key",        fnclabel},
  777. X#endif
  778. X    {"list-buffers",        listbuffers},
  779. X    {"meta-prefix",            meta},
  780. X    {"move-window-down",        mvdnwind},
  781. X    {"move-window-up",        mvupwind},
  782. X    {"name-buffer",            namebuffer},
  783. X    {"newline",            newline},
  784. X    {"newline-and-indent",        indent},
  785. X    {"next-buffer",            nextbuffer},
  786. X    {"next-line",            forwline},
  787. X    {"next-page",            forwpage},
  788. X#if    WORDPRO
  789. X    {"next-paragraph",        gotoeop},
  790. X#endif
  791. X    {"next-window",            nextwind},
  792. X    {"next-word",            forwword},
  793. X    {"open-line",            openline},
  794. X    {"pipe-command",        pipe},
  795. X    {"previous-line",        backline},
  796. X    {"previous-page",        backpage},
  797. X#if    WORDPRO
  798. X    {"previous-paragraph",        gotobop},
  799. X#endif
  800. X    {"previous-window",        prevwind},
  801. X    {"previous-word",        backword},
  802. X    {"query-replace-string",    qreplace},
  803. X    {"quick-exit",            quickexit},
  804. X    {"quote-character",        quote},
  805. X    {"read-file",            fileread},
  806. X    {"redraw-display",        reposition},
  807. X    {"resize-window",        resize},
  808. X    {"restore-window",        restwnd},
  809. X    {"replace-string",        sreplace},
  810. X#if    ISRCH
  811. X    {"reverse-incremental-search",    risearch},
  812. X#endif
  813. X    {"save-file",            filesave},
  814. X    {"save-window",            savewnd}X    {"search-forward",        forwsearch},
  815. X    {"search-reverse",        backsearch},
  816. X    {"select-buffer",        usebuffer},
  817. X    {"set",                setvar},
  818. X#if    CRYPT
  819. X    {"set-encryption-key",        setkey},
  820. X#endif
  821. X    {"set-fill-column",        setfillcol},
  822. X    {"set-mark",            setmark},
  823. X    {"shell-command",        spawn},
  824. X    {"shrink-window",        shrinkwind},
  825. X    {"split-current-window",    splitwind},
  826. X    {"store-macro",            storemac},
  827. X#if    BSD
  828. X    {"suspend-emacs",        bktoshell},
  829. X#endif
  830. X    {"transpose-characters",    twiddle},
  831. X    {"unbind-key",            unbindkey},
  832. X    {"universal-argument",        unarg},
  833. X    {"unmark-buffer",        unmark},
  834. X    {"update-screen",        upscreen},
  835. X    {"view-file",            viewfile},
  836. X    {"wrap-word",            wrapword},
  837. X    {"write-file",            filewrite},
  838. X    {"write-message",        writemsg},
  839. X    {"yank",            yank},
  840. X
  841. X    {"",            NULL}
  842. X};
  843. END_OF_efunc.h
  844. if test 14637 -ne `wc -c <efunc.h`; then
  845.     echo shar: \"efunc.h\" unpacked with wrong size!
  846. fi
  847. # end of overwriting check
  848. fi
  849. echo shar: Extracting \"termio.c\" \(12539 characters\)
  850. if test -f termio.c ; then 
  851.   echo shar: Will not over-write existing file \"termio.c\"
  852. else
  853. sed "s/^X//" >termio.c <<'END_OF_termio.c'
  854. X/*
  855. X * The functions in this file negotiate with the operating system for
  856. X * characters, and write characters in a barely buffered fashion on the display.
  857. X * All operating systems.
  858. X */
  859. X#include        <stdio.h>
  860. X#include    "estruct.h"
  861. X#include        "edef.h"
  862. X
  863. X#if    MEGAMAX & ST520
  864. Xoverlay    "termio"
  865. X#endif
  866. X
  867. X#if     AMIGA
  868. X#define NEW 1006
  869. X#define AMG_MAXBUF      1024L
  870. Xstatic long terminal;
  871. Xstatic char     scrn_tmp[AMG_MAXBUF+1];
  872. Xstatic long     scrn_tmp_p = 0;
  873. X#endif
  874. X
  875. X#if ST520
  876. X#include <osbind.h>
  877. X    int STscancode = 0;    
  878. X#endif
  879. X
  880. X#if     VMS
  881. X#include        <stsdef.h>
  882. X#include        <ssdef.h>
  883. X#include        <descrip.h>
  884. X#include        <iodef.h>
  885. X#include        <ttdef.h>
  886. X#include    <tt2def.h>
  887. X
  888. X#define NIBUF   128                     /* Input buffer size            */
  889. X#define NOBUF   1024                    /* MM says bug buffers win!     */
  890. X#define EFN     0                       /* Event flag                   */
  891. X
  892. Xchar    obuf[NOBUF];                    /* Output buffer                */
  893. Xint     nobuf;                  /* # of bytes in above    */
  894. Xchar    ibuf[NIBUF];                    /* Input buffer          */
  895. Xint     nibuf;                  /* # of bytes in above  */
  896. Xint     ibufi;                  /* Read index                   */
  897. Xint     oldmode[3];                     /* Old TTY mode bits            */
  898. Xint     newmode[3];                     /* New TTY mode bits            */
  899. Xshort   iochan;                  /* TTY I/O channel             */
  900. X#endif
  901. X
  902. X#if     CPM
  903. X#include        <bdos.h>
  904. X#endif
  905. X
  906. X#if     MSDOS & (LATTICE | MSC | AZTEC | MWC86)
  907. Xunion REGS rg;        /* cpu register for use of DOS calls */
  908. Xint nxtchar = -1;    /* character held from type ahead    */
  909. X#endif
  910. X
  911. X#if RAINBOW
  912. X#include "rainbow.h"
  913. X#endif
  914. X
  915. X#if    USG            /* System V */
  916. X#include    <signal.h>
  917. X#include    <termio.h>
  918. Xstruct    termio    otermio;    /* original terminal characteristics */
  919. Xstruct    termio    ntermio;    /* charactoristics to use inside */
  920. X#endif
  921. X
  922. X#if V7 | BSD
  923. X#undef    CTRL
  924. X#include        <sgtty.h>        /* for stty/gtty functions */
  925. X#include    <signal.h>
  926. Xstruct  sgttyb  ostate;          /* saved tty state */
  927. Xstruct  sgttyb  nstate;          /* values for editor mode */
  928. Xstruct tchars    otchars;    /* Saved terminal special character set */
  929. Xstruct tchars    ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  930. X                /* A lot of nothing */
  931. X#if BSD
  932. X#include <sys/ioctl.h>        /* to get at the typeahead */
  933. Xextern    int rtfrmshell();    /* return from suspended shell */
  934. X#define    TBUFSIZ    128
  935. Xchar tobuf[TBUFSIZ];        /* terminal output buffer */
  936. X#endif
  937. X#endif
  938. X
  939. X/*
  940. X * This function is called once to set up the terminal device streams.
  941. X * On VMS, it translates TT until it finds the terminal, then assigns
  942. X * a channel to it and sets it raw. On CPM it is a no-op.
  943. X */
  944. Xttopen()
  945. X{
  946. X#if     AMIGA
  947. X        terminal = Open("RAW:1/1/639/199/MicroEMACS 3.7/Amiga", NEW);
  948. X#endif
  949. X#if     VMS
  950. X        struct  dsc$descriptor  idsc;
  951. X        struct  dsc$descriptor  odsc;
  952. X        char    oname[40];
  953. X        int     iosb[2];
  954. X        int     status;
  955. X
  956. X        odsc.dsc$a_pointer = "TT";
  957. X        odsc.dsc$w_length  = strlen(odsc.dsc$a_pointer);
  958. X        odsc.dsc$b_dtype        = DSC$K_DTYPE_T;
  959. X        odsc.dsc$b_class        = DSC$K_CLASS_S;
  960. X        idsc.dsc$b_dtype        = DSC$K_DTYPE_T;
  961. X        idsc.dsc$b_class        = DSC$K_CLASS_S;
  962. X        do {
  963. X                idsc.dsc$a_pointer = odsc.dsc$a_pointer;
  964. X                idsc.dsc$w_length  = odsc.dsc$w_length;
  965. X                odsc.dsc$a_pointer = &oname[0];
  966. X                odsc.dsc$w_length  = sizeof(oname);
  967. X                status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
  968. X                if (status!=SS$_NORMAL && status!=SS$_NOTRAN)
  969. X                        exit(status);
  970. X                if (oname[0] == 0x1B) {
  971. X                        odsc.dsc$a_pointer += 4;
  972. X                        odsc.dsc$w_length  -= 4;
  973. X                }
  974. X        } while (status == SS$_NORMAL);
  975. X        status = SYS$ASSIGN(&odsc, &iochan, 0, 0);
  976. X        if (status != SS$_NORMAL)
  977. X                exit(status);
  978. X        status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
  979. X                          oldmode, sizeof(oldmode), 0, 0, 0, 0);
  980. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  981. X                exit(status);
  982. X        newmode[0] = oldmode[0];
  983. X        newmode[1] = oldmode[1] | TT$M_NOECHO;
  984. X        newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC);
  985. X        newmode[2] = oldmode[2] | TT2$M_PASTHRU;
  986. X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  987. X                          newmode, sizeof(newmode), 0, 0, 0, 0);
  988. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  989. X                exit(status);
  990. X        term.t_nrow = (newmode[1]>>24) - 1;
  991. X        term.t_ncol = newmode[0]>>16;
  992. X
  993. X#endif
  994. X#if     CPM
  995. X#endif
  996. X
  997. X#if     MSDOS & (HP150 == 0) & LATTICE
  998. X    /* kill the ctrl-break interupt */
  999. X    rg.h.ah = 0x33;        /* control-break check dos call */
  1000. X    rg.h.al = 1;        /* set the current state */
  1001. X    rg.h.dl = 0;        /* set it OFF */
  1002. X    intdos(&rg, &rg);    /* go for it! */
  1003. X#endif
  1004. X
  1005. X#if    USG
  1006. X    ioctl(0, TCGETA, &otermio);    /* save old settings */
  1007. X    ntermio.c_iflag = 0;        /* setup new settings */
  1008. X    ntermio.c_oflag = 0;
  1009. X    ntermio.c_cflag = otermio.c_cflag;
  1010. X    ntermio.c_lflag = 0;
  1011. X    ntermio.c_line = otermio.c_line;
  1012. X    ntermio.c_cc[VMIN] = 1;
  1013. X    ntermio.c_cc[VTIME] = 0;
  1014. X    ioctl(0, TCSETA, &ntermio);    /* and activate them */
  1015. X#endif
  1016. X
  1017. X#if     V7 | BSD
  1018. X        gtty(0, &ostate);                       /* save old state */
  1019. X        gtty(0, &nstate);                       /* get base of new state */
  1020. X        nstate.sg_flags |= RAW;
  1021. X        nstate.sg_flags &= ~(ECHO|CRMOD);       /* no echo for now... */
  1022. X        stty(0, &nstate);                       /* set mode */
  1023. X    ioctl(0, TIOCGETC, &otchars);        /* Save old characters */
  1024. X    ioctl(0, TIOCSETC, &ntchars);        /* Place new character into K */
  1025. X#if    BSD
  1026. X    /* provide a smaller terminal output buffer so that
  1027. X       the type ahead detection works better (more often) */
  1028. X    setbuffer(stdout, &tobuf[0], TBUFSIZ);
  1029. X    signal(SIGTSTP,SIG_DFL);    /* set signals so that we can */
  1030. X    signal(SIGCONT,rtfrmshell);    /* suspend & restart emacs */
  1031. X#endif
  1032. X#endif
  1033. X    /* on all screens we are not sure of the initial position
  1034. X       of the cursor                    */
  1035. X    ttrow = 999;
  1036. X    ttcol = 999;
  1037. X}
  1038. X
  1039. X/*
  1040. X * This function gets called just before we go back home to the command
  1041. X * interpreter. On VMS it puts the terminal back in a reasonable state.
  1042. X * Another no-operation on CPM.
  1043. X */
  1044. Xttclose()
  1045. X{
  1046. X#if     AMIGA
  1047. X        amg_flush();
  1048. X        Close(terminal);
  1049. X#endif
  1050. X#if     VMS
  1051. X        int     status;
  1052. X        int     iosb[1];
  1053. X
  1054. X        ttflush();
  1055. X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
  1056. X                 oldmode, sizeof(oldmode), 0, 0, 0, 0);
  1057. X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
  1058. X                exit(status);
  1059. X        status = SYS$DASSGN(iochan);
  1060. X        if (status != SS$_NORMAL)
  1061. X                exit(status);
  1062. X#endif
  1063. X#if     CPM
  1064. X#endif
  1065. X#if     MSDOS & (HP150 == 0) & LATTICE
  1066. X    /* restore the ctrl-break interupt */
  1067. X    rg.h.ah = 0x33;        /* control-break check dos call */
  1068. X    rg.h.al = 1;        /* set the current state */
  1069. X    rg.h.dl = 1;        /* set it ON */
  1070. X    intdos(&rg, &rg);    /* go for it! */
  1071. X#endif
  1072. X
  1073. X#if    USG
  1074. X    ioctl(0, TCSETA, &otermio);    /* restore terminal settings */
  1075. X#endif
  1076. X
  1077. X#if     V7 | BSD
  1078. X        stty(0, &ostate);
  1079. X    ioctl(0, TIOCSETC, &otchars);    /* Place old character into K */
  1080. X#endif
  1081. X}
  1082. X
  1083. X/*
  1084. X * Write a character to the display. On VMS, terminal output is buffered, and
  1085. X * we just put the characters in the big array, after checking for overflow.
  1086. X * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
  1087. X * MS-DOS (use the very very raw console output routine).
  1088. X */
  1089. Xttputc(c)
  1090. X#if     AMIGA | ST520
  1091. X        char c;
  1092. X#endif
  1093. X{
  1094. X#if     AMIGA
  1095. X        scrn_tmp[scrn_tmp_p++] = c;
  1096. X        if(scrn_tmp_p>=AMG_MAXBUF)
  1097. X                amg_flush();
  1098. X#endif
  1099. X#if    ST520
  1100. X    Bconout(2,c);
  1101. X#endif
  1102. X#if     VMS
  1103. X        if (nobuf >= NOBUF)
  1104. X                ttflush();
  1105. X        obuf[nobuf++] = c;
  1106. X#endif
  1107. X
  1108. X#if     CPM
  1109. X        bios(BCONOUT, c, 0);
  1110. X#endif
  1111. X
  1112. X#if     MSDOS & MWC86
  1113. X        putcnb(c);
  1114. X#endif
  1115. X
  1116. X#if    MSDOS & (LATTICE | AZTEC) & ~IBMPC
  1117. X    bdos(6, c, 0);
  1118. X#endif
  1119. X
  1120. X#if RAINBOW
  1121. X        Put_Char(c);                    /* fast video */
  1122. X#endif
  1123. X
  1124. X
  1125. X#if     V7 | USG | BSD
  1126. X        fputc(c, stdout);
  1127. X#endif
  1128. X}
  1129. X
  1130. X#if    AMIGA
  1131. Xamg_flush()
  1132. X{
  1133. X        if(scrn_tmp_p)
  1134. X                Write(terminal,scrn_tmp,scrn_tmp_p);
  1135. X        scrn_tmp_p = 0;
  1136. X}
  1137. X#endif
  1138. X
  1139. X/*
  1140. X * Flush terminal buffer. Does real work where the terminal output is buffered
  1141. X * up. A no-operation on systems where byte at a time terminal I/O is done.
  1142. X */
  1143. Xttflush()
  1144. X{
  1145. X#if     AMIGA
  1146. X        amg_flush();
  1147. X#endif
  1148. X#if     VMS
  1149. X        int     status;
  1150. X        int     iosb[2];
  1151. X
  1152. X        status = SS$_NORMAL;
  1153. X        if (nobuf != 0) {
  1154. X                status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT,
  1155. X                         iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
  1156. X                if (status == SS$_NORMAL)
  1157. X                        status = iosb[0] & 0xFFFF;
  1158. X                nobuf = 0;
  1159. X        }
  1160. X        return (status);
  1161. X#endif
  1162. X
  1163. X#if     CPM
  1164. X#endif
  1165. X
  1166. X#if     MSDOS
  1167. X#endif
  1168. X
  1169. X#if     V7 | USG | BSD
  1170. X        fflush(stdout);
  1171. X#endif
  1172. X}
  1173. X
  1174. X/*
  1175. X * Read a character from the terminal, performing no editing and doing no echo
  1176. X * at all. More complex in VMS that almost anyplace else, which figures. Very
  1177. X * simple on CPM, because the system can do exactly what you want.
  1178. X */
  1179. Xttgetc()
  1180. X{
  1181. X#if     AMIGA
  1182. X        char ch;
  1183. X        amg_flush();
  1184. X        Read(terminal, &ch, 1L);
  1185. X        return(255 & (int)ch);
  1186. X#endif
  1187. X#if    ST520
  1188. X    long ch;
  1189. X/*
  1190. X * blink the cursor only if nothing is happening, this keeps the
  1191. X * cursor on steadily during movement making it easier to track
  1192. X */
  1193. X    STcurblink(TRUE);  /* the cursor blinks while we wait */
  1194. X    ch = Bconin(2);
  1195. X    STcurblink(FALSE); /* the cursor is steady while we work */
  1196. X    STscancode = (ch >> 16) & 0xff;
  1197. X           return(255 & (int)ch);
  1198. X#endif
  1199. X#if     VMS
  1200. X        int     status;
  1201. X        int     iosb[2];
  1202. X        int     term[2];
  1203. X
  1204. X        while (ibufi >= nibuf) {
  1205. X                ibufi = 0;
  1206. X                term[0] = 0;
  1207. X                term[1] = 0;
  1208. X                status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
  1209. X                         iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
  1210. X                if (status != SS$_NORMAL)
  1211. X                        exit(status);
  1212. X                status = iosb[0] & 0xFFFF;
  1213. X                if (status!=SS$_NORMAL && status!=SS$_TIMEOUT)
  1214. X                        exit(status);
  1215. X                nibuf = (iosb[0]>>16) + (iosb[1]>>16);
  1216. X                if (nibuf == 0) {
  1217. X                        status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
  1218. X                                 iosb, 0, 0, ibuf, 1, 0, term, 0, 0);
  1219. X                        if (status != SS$_NORMAL
  1220. X                        || (status = (iosb[0]&0xFFFF)) != SS$_NORMAL)
  1221. X                                exit(status);
  1222. X                        nibuf = (iosb[0]>>16) + (iosb[1]>>16);
  1223. X                }
  1224. X        }
  1225. X        return (ibuf[ibufi++] & 0xFF);    /* Allow multinational  */
  1226. X#endif
  1227. X
  1228. X#if     CPM
  1229. X        return (biosb(BCONIN, 0, 0));
  1230. X#endif
  1231. X
  1232. X#if RAINBOW
  1233. X        int Ch;
  1234. X
  1235. X        while ((Ch = Read_Keyboard()) < 0);
  1236. X
  1237. X        if ((Ch & Function_Key) == 0)
  1238. X                if (!((Ch & 0xFF) == 015 || (Ch & 0xFF) == 0177))
  1239. X                        Ch &= 0xFF;
  1240. X
  1241. X        return Ch;
  1242. X#endif
  1243. X
  1244. X#if     MSDOS & MWC86
  1245. X        return (getcnb());
  1246. X#endif
  1247. X
  1248. X#if    MSDOS & (LATTICE | MSC | AZTEC)
  1249. X    int c;        /* character read */
  1250. X
  1251. X    /* if a char already is ready, return it */
  1252. X    if (nxtchar >= 0) {
  1253. X        c = nxtchar;
  1254. X        nxtchar = -1;
  1255. X        return(c);
  1256. X    }
  1257. X
  1258. X    /* call the dos to get a char */
  1259. X    rg.h.ah = 7;        /* dos Direct Console Input call */
  1260. X    intdos(&rg, &rg);
  1261. X    c = rg.h.al;        /* grab the char */
  1262. X    return(c & 255);
  1263. X#endif
  1264. X
  1265. X#if     V7 | USG | BSD
  1266. X        return(127 & fgetc(stdin));
  1267. X#endif
  1268. X}
  1269. X
  1270. X#if    TYPEAH
  1271. X/* typahead:    Check to see if any characters are already in the
  1272. X        keyboard buffer
  1273. X*/
  1274. X
  1275. Xtypahead()
  1276. X
  1277. X{
  1278. X#if    MSDOS & (LATTICE | AZTEC | MWC86)
  1279. X    int c;        /* character read */
  1280. X    int flags;    /* cpu flags from dos call */
  1281. X
  1282. X#if    MSC
  1283. X    if (kbhit() != 0)
  1284. X        return(TRUE);
  1285. X    else
  1286. X        return(FALSE);
  1287. X#endif
  1288. X
  1289. X    if (nxtchar >= 0)
  1290. X        return(TRUE);
  1291. X
  1292. X    rg.h.ah = 6;    /* Direct Console I/O call */
  1293. X    rg.h.dl = 255;    /*         does console input */
  1294. X#if    LATTICE | AZTEC
  1295. X    flags = intdos(&rg, &rg);
  1296. X#else
  1297. X    intcall(&rg, &rg, 0x21);
  1298. X    flags = rg.x.flags;
  1299. X#endif
  1300. X    c = rg.h.al;    /* grab the character */
  1301. X
  1302. X    /* no character pending */
  1303. X    if ((flags & 64) != 0)
  1304. X        return(FALSE);
  1305. X
  1306. X    /* save the character and return true */
  1307. X    nxtchar = c;
  1308. X    return(TRUE);
  1309. X#endif
  1310. X
  1311. X#if    BSD
  1312. X    int x;    /* holds # of pending chars */
  1313. X
  1314. X    return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x);
  1315. X#endif
  1316. X    return(FALSE);
  1317. X}
  1318. X#endif
  1319. X
  1320. END_OF_termio.c
  1321. if test 12539 -ne `wc -c <termio.c`; then
  1322.     echo shar: \"termio.c\" unpacked with wrong size!
  1323. fi
  1324. # end of overwriting check
  1325. fi
  1326. echo shar: End of archive 5 \(of 14\).
  1327. cp /dev/null ark5isdone
  1328. MISSING=""
  1329. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1330.     if test ! -f ark${I}isdone ; then
  1331.     MISSING="${MISSING} ${I}"
  1332.     fi
  1333. done
  1334. if test "${MISSING}" = "" ; then
  1335.     echo You have unpacked all 14 archives.
  1336.     echo "See the readme file"
  1337.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1338. else
  1339.     echo You still need to unpack the following archives:
  1340.     echo "        " ${MISSING}
  1341. fi
  1342. ##  End of shell archive.
  1343. exit 0
  1344.